<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html >
<html lang="en">
<head>
<%@include file="../../common/includeBaseSet.jsp" %>
<%@include file="../../common/includeSystemSet.jsp" %>
<%@include file="../../common/operation_forbid.jsp" %>
<%@include file="../../common/jsVersion.jsp" %>
<link rel="stylesheet" type="text/css"  href="${jypath}/static/ext/resources/ext-theme-gray/ext-theme-gray-all.css" />
<script type="text/javascript" src="${jypath}/static/ext/ext-all.js"></script>
<script type="text/javascript" src="${jypath}/static/ext/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="${jypath}/static/js/components/roomInfoComponent.js?v=${jsVersion}"></script> 
<style type="text/css">
	a{cursor:pointer}
</style>
</head>
<body>
    <div class="page-content">
        <form id="baseForm" class="form-horizontal">
            <input type='hidden' class='pageNum' name='pageNum' value='1'/>
            <input type='hidden' class='pageSize' name='pageSize' value='10'/>
	        <div class="col-xs-12 panel panel-default">
	        	<div style="margin-top:1%">
		            <div class="col-xs-5">
		                <div class="form-group">
		                    <label class="col-xs-3 control-label">项目名称:</label>
		                    <div class="col-xs-6">
		                        <select class="form-control" id="projectId" name="projectId" onchange="loadUserCode()">
		                        	<!-- 项目名称 -->
		                        </select>
		                    </div>
		                </div>
						<div class="form-group">
							<label class="col-xs-3 control-label">经纪人:</label>
							<div class="col-xs-6">
								<select class="form-control" id="userCode" name="userCode">
									<!-- 经纪人-->
								</select>
							</div>
						</div>
		            </div>
		            <div class="col-xs-5">
		                <div class="form-group">
		                    <div style="margin-left:40px">
		                        <button id='searchBtn' class="btn btn-warning  btn-xs"  style="width:70px;"
		                            title="导出" type="button" onclick="exportExcel()">
		                            <i class="bigger-110 icon-only">导出</i>
		                        </button>&nbsp;&nbsp;
		                        <button id='searchBtn' class="btn btn-warning  btn-xs"  style="width:70px;"
		                            title="清空" type="button" onclick="empty()">
		                            <i class="bigger-110 icon-only">清空</i>
		                        </button>&nbsp;&nbsp;
		                        <button id='searchBtn' class="btn btn-warning  btn-xs"  style="width:70px;"
		                            title="查询" type="button" onclick="JY.Page.jump('baseForm',1,'selectOverduePaymentPage')">
		                            <i class="bigger-110 icon-only">查询</i>
		                        </button>
		                    </div>
		                </div>
		            </div>
	            </div>
	        </div>
	    </form>
        <div class="col-xs-12">
            <table id="baseTable" class="table table-striped table-bordered table-hover">
                <thead>
                    <tr>
                        <th class="center">编号</th>
                        <th class="center">客户姓名</th>
                        <th class="center">联系电话</th>
                        <th class="center">客户性别</th>
                        <th class="center">房号</th>
                        <th class="center">签约面积</th>
                        <th class="center">签约单价</th>
                        <th class="center">签约金额</th>
                        <th class="center">房款类型</th>
                        <th class="center">应收金额</th>
						<th class="center">已收金额</th>
						<th class="center">未收金额</th>
                        <th class="center">应收日期</th>
                        <th class="center">逾期天数</th>

                    </tr>
                </thead>
                <tbody><!-- 内容 --></tbody>
            </table>
            <div class="row">
                <div class="col-sm-8">
                    <!--设置分页位置-->
                    <div id="pageing" class="dataTables_paginate paging_bootstrap">
                        <ul class="pagination"></ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- #dialog-confirm -->
        <%@include file="../../common/dialog.jsp"%>
    </div>
</body>
<script type="text/javascript">
	$(function(){
		loadProject();
		expiredDays();
        selectOverduePaymentPage();
	});
	//获取项目
	function loadProject(){
		$.ajax({
			type: 'post',
            url: '${jypath}/estate/project/findProjectList',
            data:{
            	"resourcesCode": "menu_0003_0001",
            	"resourcesName": "resName_pro_list"
            },
            dataType: 'json',
            success: function(data){
            	var root = data.root;
            	var html = '<option value="">全部</option>';
            	for (var i = 0; i < root.length; i++){
            		var info = root[i];
            		html += '<option value="' + info.id + '">' + info.projectName + '</option>';
            	}
            	$("#projectId").html(html);
            	//获取经纪人
            	loadUserCode();
            }
        });
	}
	//获取经纪人
	function loadUserCode(){
		$.ajax({
			type: 'post',
            url: '${jypath}/customer/customer/userByProjectIdForGroup',
            data:{
            	"resourcesCode": "menu_0006_0001",
            	"isList": "1",
            	"projectId": $("#projectId").val()
            },
            dataType: 'json',
            success: function(data){
            	var html = '';
            	for (var i = 0; i < data.length; i++){
            		var info = data[i];
            		html += '<option value="' + info.userCode + '">' + info.userName + '</option>';
            	}
            	$("#userCode").html(html);
            }
        });
	}
	//到期天数
	function expiredDays(){
		var html = '';
		for (var i = 10; i >= 1; i--){
			html += '<option value="' + i + '">' + i + '天</option>';
		}
		$("#day").html(html);
	}
	//查询列表
	function selectOverduePaymentPage(){
		var loadIndex = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
		JY.Ajax.doRequest("baseForm",jypath +'/backstage/selectOverduePaymentPage',null,function(data){
            $("#baseTable tbody").empty();
            var page = data.obj;
            //分页数据
            var pageNum = page.pageNumber, pageSize = page.pageSize, totalRecord = page.total;
            var html = "";
            var results = page.rows;
            if(results == null || results.length <= 0){
            	html+="<tr><td colspan='14' class='center'>没有相关数据</td></tr>";
                $("#baseTable tbody").append(html);
                $("#pageing ul").empty();//清空分页
                layer.closeAll('loading');
                return false;
            }
          
            var leng=(pageNum-1)*pageSize;//计算序号
            for(var i = 0; i < results.length; i++){
                var info = results[i];
                html += "<tr>";
                html += "<td class='center'>" + (leng + i + 1) + "</td>";
                html += "<td class='center'>" + info.customer_name + "</td>";
                html += "<td class='center'>" + info.customerPhone + "</td>";
                html += "<td class='center'>" + (info.customerSex==1?'男':'女') + "</td>";
                html += "<td class='center'><a style='text-decoration:none;' href='javascript:openWindow("+info.roomId+")'>" + info.combined_name + "</a></td>";
                html += "<td class='center'>" + info.calculatArea + "</td>";
                html += "<td class='center'>" + info.price + "</td>";
                html += "<td class='center'>" + info.totalPrice + "</td>";
                html += "<td class='center'>" + info.receivablesFunds + "</td>";
                html += "<td class='center'>" + info.totalReceivablesAmount + "</td>";
                html += "<td class='center'>" + (info.receivedAmount==null?0:info.receivedAmount) + "</td>";
                html += "<td class='center'>" + (info.uncollectedAmount==null?0:info.uncollectedAmount) + "</td>";
                html += "<td class='center'>" + JY.Date.Format(info.receivablesDate, 'yyyy-MM-dd') + "</td>";
                html += "<td class='center'>" + info.overdueDay + "天</td>";
                html += "</tr>";
            }
            $("#baseTable tbody").append(html);
            JY.Page.setPage("baseForm","pageing",pageSize,pageNum,totalRecord,"selectOverduePaymentPage");
            layer.closeAll('loading');
		});
	}
	
	//清空查询选项
	function empty(){
		$("#projectId").val("");
		loadUserCode();
		$("#day").val("10");
	}
	//导出列表
	function exportExcel(){
		var projectId = $("#projectId").val();
		var userCode = $("#userCode").val();
		location.href = jypath +'/backstage/exportOverduePaymentList?projectId='+projectId+'&userCode='+userCode;
	}
	
	var maketingRetainAdd = false;
	var marketingSubscribeAdd = false;
	var marketingSignedAdd = false;
	var marketingSellControlAdd = false;
	function openWindow(roomId){
		 //弹出详情框
		 var windowInfo=Ext.create('component.room.InfoWindow',{
			 roomId:roomId,
			 jumpFlag:'1'
		 });
		 windowInfo.show();
	}
</script>
</html>